<meta charset="UTF-8" />
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <link rel="stylesheet" href="/layui/css/layui.css"/>

</head>
<style type="text/css">
    .myData .layui-form-item{
        margin: 20px 100px 10px 45px;
    }
    .myData .layui-form-label{
        width: 85px;
    }
    .layui-input-block {
        margin-left: 120px;
    }
</style>
<div class="layui-form">
<form class="layui-form myData"  id="saveForm" action="" method="post" lay-filter="stuform">

     <div class="layui-form-item" >
        <label class="layui-form-label">角色标识：</label>
        <div class="layui-input-block">
            <input type="text" name="name" onkeyup="value=value.replace(/[^a-zA-Z]/g,'')"  placeholder="仅支持全英文"  class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label">角色标识：</label>
        <div class="layui-input-block">
            <input type="text" name="notes"   class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
                 <button type="button" onclick="save()" class="layui-btn" >立即提交</button>

        </div>
    </div> 
</form>
</div>
 <script type="text/javascript" src="/layui/layui.all.js"></script>
  <script type="text/javascript" src="/layui/layui.js"></script>
 
<script type="text/javascript" src="/js/jquery/jquery-3.3.1.min.js"></script>
<script th:inline="javascript">     
    function save(){    
                $.ajax({
                    type:"post",
                    url:"/role/saveRole",
                    data: $('#saveForm').serialize(),//表单数据
                    success:function(d){
                        if(d=="success"){
                              /* layer.msg("更新成功！"); */
				    		 //当你在iframe页面关闭自身时
	 	         		    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	              			  //layer信息提示
	              		 layer.msg('保存成功');//下面是关键代码
		 	           	 setTimeout(function () { parent.layer.close(index) }, 330);//延迟
		 	              
                        }
                        else{
                            layer.msg(d);
                        }
                        
						setTimeout(function (){
						 
							 window.parent.location.reload();
						}, 500);
                    }
                })
    }
    
   
</script>
</html>